﻿/*****************************************************************//**
 * @file    FITKGraphObjectMaterialOrientation.h
 * @brief   Graph object for 'material orientation' of part.
 *
 * @author  ChengHaotian (yeguangbaozi@foxmail.com)
 * @date    2024-06-07
 *********************************************************************/

#ifndef __FITKGRAPHOBJECTMATERIALORIENTATION_H__
#define __FITKGRAPHOBJECTMATERIALORIENTATION_H__

#include "FITKGraphObjectMarkBase.h"

#include "FITKVTKGraphAdaptorAPI.h"

// Forward declaration
class vtkPoints;
class vtkCellArray;
class vtkPolyData;
class vtkUnstructuredGrid;
class vtkIntArray;
class vtkCell;
class vtkPointSource;
class vtkGlyph3D;

class FITKGraphActor;

namespace Interface
{
    class FITKAbaMaterialOrientation;
}

namespace Exchange
{
    /**
     * @brief   Graph object for 'material orientation' of part.
     * @author  ChengHaotian (yeguangbaozi@foxmail.com)
     * @date    2024-06-07
     */
    class FITKVTKGRAPHADAPTORAPI FITKGraphObjectMaterialOrientation : public FITKGraphObjectMarkBase
    {
        // Regist
        FITKGraphObjectRegist(FITKGraphObjectMaterialOrientation, FITKGraphObjectMarkBase);
        FITKCLASS(Exchange, FITKGraphObjectMaterialOrientation);

    public:
        /**
         * @brief   Constructor.
         * @param   caseData: The case data
         * @param   matOriData: The material orientation data object
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-06-07
         */
        FITKGraphObjectMaterialOrientation(AbaqusData::FITKDataCase* caseData, Interface::FITKAbaMaterialOrientation* matOriData);

        /**
         * @brief   Destructor.[virtual]
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-06-07
         */
        virtual ~FITKGraphObjectMaterialOrientation();

        /**
         * @brief   Show or hide graph object.[virtual][override]
         * @param   visibility: The visibility of graph object
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-06-07
         */
        virtual void setVisible(bool visibility) override;

        /**
         * @brief   Highlight the interactions or constraint graph actors.[virtual][override]
         * @param   color: The given color for highlighting this time[default]
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-06-07
         */
        virtual void highlight(QColor color = QColor()) override;

        /**
         * @brief   Dis-highlight the interactions or constraint graph actors.[virtual][override]
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-06-07
         */
        virtual void disHighlight() override;

        /**
         * @brief   Update all graph actors.[virtual][override]
         * @param   forceUpdate: Force update[default]
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-06-07
         */
        virtual void update(bool forceUpdate = false) override;

        /**
         * @brief   Update the visibility with data object's visibility.[virtual][override]
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-06-07
         */
        virtual void updateVisibility() override;

        /**
         * @brief   Simplified the graph object if necessary.[virtual][override]
         * @param   enabled: Enabled simplified flag
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-06-07
         */
        virtual void simplified(bool enabled) override;

        /**
         * @brief   If the graph object has relation with the given data object id.[virtual][override]
         * @param   dataObjId: The data object id
         * @return  Has relation
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-06-07
         */
        virtual bool isRelatedTo(int dataObjId) override;

    protected:
        /**
         * @brief   Initialize.
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-06-07
         */
        void init();

        /**
         * @brief   Initialize the actors.[virtual]
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-06-07
         */
        virtual void initActors();

        /**
         * @brief   Clear the data.[override]
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-06-07
         */
        void clearData() override;

        /**
         * @brief   Generate interactions or constraint actor.[override]
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-06-07
         */
        void generateGraph() override;

        /**
         * @brief   Generate the poly data for the material orientation.
         * @param   matOriData: The material orientation data object
         * @return  Is OK
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-06-07
         */
        bool generatePolyData(Interface::FITKAbaMaterialOrientation* matOriData);

        /**
         * @brief   Get the visibility from the data object.[override]
         * @return  The visibility
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-06-07
         */
        bool getDataVisibility() override;

    private:
        /**
         * @brief   The grid data for glyphs.
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-06-07
         */
        vtkUnstructuredGrid* m_ugrid{ nullptr };

        /**
         * @brief   The glyph size of the shape.
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-06-07
         */
        double m_glyphSize = 70.;

        /**
         * @brief   The points data for orientation glyphs.
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-06-07
         */
        vtkPoints* m_points{ nullptr };

        /**
         * @brief   The glyph filter.
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-06-07
         */
        vtkGlyph3D* m_glyph{ nullptr };

        /**
         * @brief   The graph actor for orientation glyphs.
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-06-07
         */
        FITKGraphActor* m_fActor{ nullptr };

        /**
         * @brief   The orientation's set id.
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-06-07
         */
        int m_componentId = -1;

    };
}   // namespace Exchange

#endif // __FITKGRAPHOBJECTMATERIALORIENTATION_H__
